﻿
namespace TOPTECH.Labs.OpenClosed.Correct
{
    using Strategies;

    public class Person
    {
        /// <summary>
        /// Gets or sets the persons' gender.
        /// </summary>
        /// <remarks>
        /// There are only two genders, right?
        /// Let's make it the easy way.
        /// Just to remember:
        /// 0 = male
        /// 1 = female 
        /// </remarks>
        public Gender Gender { get; set; }

        /// <summary>
        /// Gets or sets the persons' marriage status.
        /// </summary>
        public Status Status { get; set; }

        /// <summary>
        /// Gets or sets the persons' age.
        /// </summary>
        public int Age { get; set; }

        /// <summary>
        /// Gets or sets whether the person is known.
        /// </summary>
        public bool Known { get; set; }

        /// <summary>
        /// Gets or sets the persons' name.
        /// </summary>
        public string Name { get; set; }

        public Person()
            : this("John")
        {
        }

        public Person(string name)
        {
            this.Name = name;
        }

        /// <summary>
        /// Returns a description of the person based on her
        /// properties.
        /// </summary>
        public override string ToString()
        {
            var result = string.Empty;

            if (this.Known)
            {
                if (this.Age >= 18)
                {
                    result = "{0} is a known " + this.Gender + " " + this.Status + " adult.";
                }
                else
                {
                    result = "{0} is a known " + this.Gender + " " + this.Status + " child.";
                } // Age
            }
            else
            {
                if (this.Age >= 18)
                {
                    result = "{0} is a unknown " + this.Gender + " " + this.Status + " adult.";
                }
                else
                {
                    result = "{0} is a unknown " + this.Gender + " " + this.Status + " child.";
                } // Age
            } // Exists

            return string.Format(result, this.Name);
        }
    }
}
